<template>
    <div class="todo">
        <div class="head">
            <div>
                <el-button
                    type="primary"
                    class="btn-blue"
                    @click="audit"
                    size="small"
                    style="margin-right: 15px"
                    v-if="radio === 1 && isDone === 1 && showType"
                    >批量审核</el-button
                >
                <el-button
                    type="primary"
                    class="btn-blue"
                    size="small"
                    style="margin-right: 15px"
                    v-if="radio === 2 && isDone === 1"
                    >全部标为已读</el-button
                >
                <el-button
                    type="primary"
                    class="btn-blue"
                    size="small"
                    style="margin-right: 15px"
                    v-if="radio === 3 && isDone === 1"
                    >全部标为已读</el-button
                >
                <el-radio-group v-model="radio">
                    <el-radio :label="1">待办事项</el-radio>
                    <el-radio :label="2">异常预警</el-radio>
                    <el-radio :label="3">系统通知</el-radio>
                </el-radio-group>
            </div>
            <div>
                <el-radio-group v-model="isDone" v-if="radio === 1" @change="cutDone">
                    <el-radio :label="1">待办</el-radio>
                    <el-radio :label="2">已办</el-radio>
                </el-radio-group>
                <el-radio-group v-model="isDone" v-if="radio === 2">
                    <el-radio :label="1">待处理</el-radio>
                    <el-radio :label="2">已处理</el-radio>
                </el-radio-group>
                <el-radio-group v-model="isDone" v-if="radio === 3">
                    <el-radio :label="1">未读</el-radio>
                    <el-radio :label="2">已读</el-radio>
                </el-radio-group>
            </div>
            <div
                style="
                    cursor: pointer;
                    color: #3767d8;
                    display: flex;
                    align-items: center;
                "
            >
                <img
                    class="batchicon"
                    src="@/assets/btn/cancelDelete.png"
                    style="height: 19px; margin-right: 5px"
                    @click="toggle"
                />
                <p style="white-space: nowrap" @click="toggle">
                    {{ model }}
                </p>

                <el-input
                    placeholder="请输入关键字"
                    v-model="search"
                    size="small"
                    style="margin-left: 15px"
                    @blur="handleSearch"
                    @keydown.enter.native="fuzzySearchEnter"
                >
                    <i slot="suffix" class="el-icon-search like" @click="handleSearch"></i>
                </el-input>
            </div>
        </div>
        <div class="todo-content">
            <todoList
                v-if="radio === 1"
                :showType="showType"
                :isDone="isDone"
                :search.sync="search"
                ref="child"

            />
            <warnList
                v-if="radio === 2"
                :showType="showType"
                :isDone="isDone"
            />
            <noticeList
                v-if="radio === 3"
                :showType="showType"
                :isDone="isDone"
            />
        </div>
    </div>
</template>
<script>
import todoList from '@/pages/todo/todoList'   //代办事项
import warnList from '@/pages/todo/warnList'  //异常预计
import noticeList from '@/pages/todo/noticeList' //系统通知

export default {
    name: 'TodoList',
    components: {
        todoList,
        warnList,
        noticeList
    },
    computed: {},
    data () {
        return {
            showType: false,
            auditType: '', // 审核状态：待办单项todoSingle 待办批量todoAll
            radio: 1, //1：待办，2：预警，3：消息通知
            isDone: 1,
            search: '', //搜索
            model: '切换到列表模式',
        }
    },
    created () {
    },
    mounted () {
        const pageType = this.$route.query.pageType
        if(pageType) {
            this.radio = parseInt(pageType)
        }
    },
    methods: {
        //批量审核
        audit () {
            this.$refs.child.onAllAudit()
        },
        //切换待办/已办
        cutDone () {
            this.search = ''
            // this.handleSearch()
        },
        toggle () {
            this.showType = !this.showType
            this.showType
                ? (this.model = '切换到标准模式')
                : (this.model = '切换到列表模式')
        },
        handleSearch () {
            this.$refs.child.handleSearch()
        },
        fuzzySearchEnter (e) {
            if(e.keyCode == 13) {
                this.handleSearch()
            }
        }
    }
}
</script>
<style lang="scss" scoped>
.ws-backlog-block {
    border: 1px solid #eee;
    background: #fff;
    margin: 20px 10px 0px 10px;
    border-radius: 7px;
    box-shadow: 1.4px 1.4px 11.6px 1.4px rgba(4, 0, 0, 0.1);
    .ws-backlog-block-head {
        height: 39px;
        border-bottom: 1px solid #f2f2f2;
        position: relative;
    }
    .ws-title {
        display: block;
        width: calc(100% - 80px);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        float: left;
        line-height: 39px;
        padding-left: 10px;
    }
    .ws-more {
        display: inline-block;
        height: 20px;
        line-height: 20px;
        padding: 0 6px;
        // background: #f57c00;
        color: #ff0000;
        font-size: 12px;
        border-radius: 3px;
        position: absolute;
        right: 10px;
        top: 10px;
    }
    .ws-backlog-block-orgName {
        height: 60px;
        line-height: 30px;
        overflow: hidden;
        padding: 5px 15px;
        font-size: 12px;
        word-break: break-all;
        word-wrap: break-word;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        color: #3264d8;
        text-decoration: none;
    }
    .ws-backlog-block-content {
        height: 60px;
        line-height: 30px;
        overflow: hidden;
        padding: 5px 15px;
        font-size: 12px;
        word-break: break-all;
        word-wrap: break-word;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        color: #333;
    }

    .ws-backlog-block-bottom {
        // border-top: 1px solid #eee;
        height: 40px;
        line-height: 40px;
        .ws-project-number,
        .ws-time {
            display: inline-block;
            height: 40px;
            line-height: 40px;
            padding: 0px 20px 0 10px;
            color: #a9b7b7;
            word-break: keep-all;
            white-space: nowrap;
            max-width: 112px;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .l-button {
            background: #fff;
            display: inline-block;
            overflow: hidden;
            cursor: pointer;
            position: relative;
            text-align: center;
            border: solid 1px #dddddd;
            color: #333333;
            padding: 0 15px;
            border-radius: 3px;
            user-select: none;
            margin: 10px 10px 0 0px;
            height: 20px;
            line-height: 20px;
        }
        .ws-blue {
            background: #2e61d7;
            border: 1px solid #2e61d7;
            color: #fff;
        }
    }
}
.todo {
    .head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-top: 10px;
        padding: 0 15px;
        height: 40px;
        background: #fff;
        box-shadow: 1.4px 1.4px 11.6px 1.4px rgba(4, 0, 0, 0.1);
    }
    .todo-content {
        width: 100%;
        height: calc(100% - 40px);
    }
    .container {
        position: relative;
    }
    .handle-box {
        position: absolute;
        right: 10px;
        top: 5px;
        z-index: 3;
    }
    .ls {
        display: flex;
        flex-wrap: wrap;
        li {
            margin: 0 0.15% 20px;
            width: 33%;
        }
    }
    .table {
        margin: 10px 0;
    }
}
</style>
